# - Try to find SelfDebug library and headers
# Once done, this will define
#
#  SELF_DEBUG_FOUND - system has SelfDebug
#  SELF_DEBUG_INCLUDE_DIR - the SelfDebug include directories
#  SELF_DEBUG_LIBRARIES - link these to use SelfDebug

if (SELF_DEBUG_INCLUDE_DIR AND SELF_DEBUG_LIBRARIES)
	set(SELF_DEBUG_FIND_QUIETLY TRUE)
endif ()

if (SELF_DEBUG_INSTALL_PATH)
	find_path(SELF_DEBUG_INCLUDE_DIR
			NAMES sd/SelfDebug.h
			PATHS ${SELF_DEBUG_INSTALL_PATH}/include
			NO_DEFAULT_PATH)
	if (NOT CYGWIN)
		find_library(SELF_DEBUG_LIBRARIES
				NAMES SelfDebug
				PATHS ${SELF_DEBUG_INSTALL_PATH}/lib
				NO_DEFAULT_PATH)
	endif ()
else ()
	find_path(SELF_DEBUG_INCLUDE_DIR
			NAMES sd/SelfDebug.h)
	if (NOT CYGWIN)
		find_library(SELF_DEBUG_LIBRARIES
				NAMES SelfDebug)
	endif ()
endif ()

include(FindPackageHandleStandardArgs)
if (NOT CYGWIN)
	find_package_handle_standard_args(SELF_DEBUG DEFAULT_MSG SELF_DEBUG_INCLUDE_DIR SELF_DEBUG_LIBRARIES)
else ()
	find_package_handle_standard_args(SELF_DEBUG DEFAULT_MSG SELF_DEBUG_INCLUDE_DIR)
endif ()

if (NOT SELF_DEBUG_FOUND)
	MESSAGE(SEND_ERROR "SelfDebug install path is invalid or cannot to be find, please install it or specify it by \"-DSELF_DEBUG_INSTALL_PATH=<value>\".")
endif ()

if (NOT CYGWIN)
	mark_as_advanced(SELF_DEBUG_INCLUDE_DIR SELF_DEBUG_LIBRARIES)
else ()
	mark_as_advanced(SELF_DEBUG_INCLUDE_DIR)
endif ()
